# -*- coding: utf-8 -*-
# PDF → TXT

import pdfplumber, os, config
from pathlib import Path
Path(config.TXT_DIR).mkdir(exist_ok=True)

for pdf in config.RAW_DIR.glob("*.pdf"):
    txt_path = config.TXT_DIR / f"{pdf.stem}.txt"
    with pdfplumber.open(pdf) as doc:
        text = "\n".join(page.extract_text() or "" for page in doc.pages)
    txt_path.write_text(text, encoding="utf-8")
print("✅ PDF 转 TXT 完毕")

